Repository navigation
feat(linearscale): rating sub type with stars, hearts or thumbs - #3637
global-prog wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@global-prog thanks for the PR :) please add the AI section to the description if you used AI to generate this PR 👍🏻 some comments on the code itself: as this uses mostly the same logic as linear scale questions, we should re-use the existing extraSettings (especially Perhaps you could also add a screenshot/recording of how it works to the description so that the @nextcloud/designers could have a look at it without having to build it 👍🏻 |
|
Thanks! Done in the latest commit:
I've added the AI declaration to the description, and I'll add a screenshot of the editor and the filled-in form there as well. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
|
@global-prog are you still working on this (and the other PRs) ? |
29ea986 to
4286aff
Compare
53cdd63 to
ac8fdb6
Compare
|
@Chartman123 I rebased this onto current main and added two fixes on top of your review commit:
I also checked the icon colours in the light, dark and both high contrast themes: stars use |
oh, my bad... I confused the two there 🙈 |
86c7ff1 to
018092d
Compare
018092d to
3a34498
Compare
d61940d to
d8cbf79
Compare
AndyScherzinger
left a comment
There was a problem hiding this comment.
Review with a focus on performance, accessibility, security, clean code and architecture, plus an accessibility check of the rating on a Nextcloud 36 instance built from this branch: editor, submit view logged in, public link, embedded form, dark mode, forced colors, 320 px reflow and the results summary. axe-core 4.10 reports no violations for the rating, and keyboard use, the focus ring, the 34 px targets and the contrast of the icons (3.5:1 to 11.9:1 against the background) pass. The only axe hits are role="false" attributes inside the question menus, which come from @nextcloud/vue and show up in every question menu. No performance or security problems turned up: the rating settings are checked against a whitelist on update, and nothing a user enters reaches its CSS or HTML.
The findings are inline. Fixes for problems this PR introduced are fixups of the commits that introduced them; problems that already exist on main are fixed in separate commits at the end of the branch. The updated branch follows this review.
Assisted by Claude Code:claude-opus-5-5
AndyScherzinger
left a comment
There was a problem hiding this comment.
Two more findings from a final pass over the tests of this PR.
Assisted by Claude Code:claude-opus-5-5
54c9dd6 to
67cdd69
Compare
AndyScherzinger
left a comment
There was a problem hiding this comment.
Second review round, again with a focus on performance, accessibility, security, clean code and architecture, plus an accessibility check on a Nextcloud 36 instance built from this branch: editor, submit view logged in, public link and embedded form, dark mode, forced colors, and widths of 320 and 360 px. axe-core 4.10 reports no violations for the rating; the only hits are the known role="false" attributes that @nextcloud/vue puts into the question menu. The names and description of the rating, its focus ring, forced colors, and moving on with Enter from ratings, radios, short answers and the answer "Other" work in all three submit contexts. Psalm, php-cs-fixer, ESLint and Stylelint pass, composer openapi reproduces openapi.json, and the unit tests pass except three UploadedFilesShareServiceTest cases that fail on Nextcloud 36 for a mock type this PR does not touch. No performance or security problems turned up.
The findings are inline. The fixes are fixups of the commits that introduced them, covered by the rating and jump e2e tests; the updated branch follows this review.
Assisted by Claude Code:claude-opus-5-5
ef71165 to
b1926e3
Compare
AndyScherzinger
left a comment
There was a problem hiding this comment.
Third and final review round, again with a focus on performance, accessibility, security, clean code and architecture, plus a check on a Nextcloud 36 instance built from this branch: the editor with the question menu and the jump targets, the submit view logged in, through a public link and embedded, and the results summary. axe-core 4.14 reports no violations for the rating in any of them; the only hits are inside the question menu (role="false", aria-checked on its labels, and <li> items in a list with role="dialog"), which come from @nextcloud/vue and appear in every question menu. Keyboard use works in all three submit contexts: Enter moves from a short answer into the rating and on to the next question, arrow keys and Space choose a value, Ctrl+Enter submits or focuses the required rating with its error, and Enter keeps its own meaning in the date picker and the dropdown. Neither Ctrl+Enter pressed twice nor a held Enter sends a response twice, as the form unmounts while it is sent. The server rejects "0", "8", "05", "5.0", " 5" and true as rating answers, and unknown icons and bounds in the settings.
The findings are inline. The fixes are fixups of the commits that introduced them, covered by two new rating e2e tests, and the updated branch is pushed. ESLint, Stylelint and the build pass, Prettier flags no file the base branch does not flag already, npm run typecheck reports the same errors with and without the fixes (it already fails for every question component, and CI does not run it), the PHP unit tests pass apart from the three UploadedFilesShareServiceTest cases that fail on Nextcloud 36, and the Playwright suite passes.
Assisted by Claude Code:claude-opus-5-5
Rating, promoter score and linear scale: one question type with sub typesI compared this PR, #3637 (rating) / #3635 (promoter score) and the linear scale on Why sub types, not separate types
Why not an on/off setting (the current state of #3635)
What it takes
The sub type lock comes first as its own small PR. Then #3635 replaces its I will be working on this myself, in follow-up commits on both PRs; your existing commits stay as they are. @global-prog, thanks for both features, shout if you see a problem with this direction. Assisted by ClaudeCode:claude-opus-5-5 |
A rating ("how would you rate this") is answered with one whole number
from 1 to N, which a linear scale already stores, validates, counts in
the results and exports. Drawn as a row of radio buttons with labels,
though, it is not the compact control people expect for it.
The rating is therefore a sub type of the linear scale, fixed when the
question is created and stored in extraSettings.questionType, the way
grid questions store their cell type. The add-question menu lists
"Numbers" and "Rating" under "Linear scale". A rating draws stars,
hearts or thumbs up (extraSettings.ratingIcon) instead of the radio
buttons and labels, still built from real radio inputs: each is named
"3 of 5", has a hit area of --default-clickable-area, the icons wrap,
and the hover effect is dropped under reduced motion. The editor offers
the highest rating (2 to 10, default 5) and the icon.
Answers, results and exports go through the existing linear scale
paths; the results summary names a rating "Linear scale (Rating)"
instead of listing scale labels it never shows.
The server accepts no other sub type of a linear scale, keeps a rating
starting at 1, and accepts ratingIcon only on a rating. Existing linear
scale questions have no sub type and stay as they are.
Closes nextcloud#2608
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Create the question through "Linear scale" > "Rating" and check what unit tests cannot: the accessible names of the rating and its options, restoring an answer from a draft and when editing a response, the error of a required rating, focus and the insert menu of a new rating, and the highest rating and the icon chosen in the editor. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
b1926e3 to
eef4c87
Compare
|
I rewrote this branch as the rating sub type of the linear scale, as proposed in #3637 (comment). It is now two commits on What moved out of this PR:
Assisted by ClaudeCode:claude-opus-5-5 |
|
This PR couldn't be reopened after its base was switched to Assisted by ClaudeCode:claude-opus-5-5 |
Closes #2608.
A rating question ("how would you rate this?") drawn as stars, hearts or thumbs up, from 1 to N icons (N from 2 to 10, default 5). A linear scale already stores, validates, counts and exports exactly this kind of answer, but draws it as a row of radio buttons with labels, which is wider and not the control people expect for a rating.
Based on the work of @global-prog in the original version of this PR, which added the rating as a question type of its own.
Rating as a sub type of the linear scale
Following the design discussed in this PR, the rating is not a new question type but a sub type of
linearscale, fixed when the question is created and stored inextraSettings.questionType, the way grid questions store their cell type:extraSettings.ratingIcon:star,heartorthumb).FormsQuestionType, no migration.ratingIconon anything but a rating.newQuestion'ssubtypeparameter is widened toFormsQuestionSubtype(openapi.jsonregenerated,docs/API_v3.mdanddocs/DataStructure.mdupdated).The promoter score sub type of #3635 follows the same pattern, and a separate PR makes the sub type immutable after creation.
Accessibility
The rating is built from real radio inputs: each option is named "3 of 5", the hit area is a full
--default-clickable-areasquare while the icon stays at 34 px, the focus ring shows for keyboard focus, the hover effect is dropped underprefers-reduced-motion, and the icons wrap on narrow screens. A required rating left empty shows "You must answer this question" and marks its radios invalid.How to verify
Checked on a Nextcloud 35 test instance in the editor, the submit view logged in, a public link (360 px wide, reduced motion) and an embedded form (dark): axe-core reports no violations, keyboard answering and submitting works in all three, and the results summary counts the rating per value. PHPUnit (FormsService, ApiController, SubmissionService), ESLint, Stylelint, Prettier and the build pass,
vue-tscreports no new errors, and the full Playwright suite passes (70 tests).🤖 AI (if applicable)